package cn.itsource.hrm.client;

import cn.itsource.hrm.domain.LoginUser;
import cn.itsource.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginUserClientFallbackFactory implements FallbackFactory<LoginUserClient> {
    @Override
    public LoginUserClient create(Throwable throwable) {
        return new LoginUserClient() {
            @Override
            public AjaxResult addOrUpdate(LoginUser loginUser) {

                log.error("远程保存登录用户失败！");
                return AjaxResult.me().setSuccess(false).setMessage("啊，降级啦....");
            }
        };
    }
}
